{extend name='base' /}

{block name='main'}
<link rel="stylesheet" href="__CSS__/bookinfo.css">
<nav aria-label="breadcrumb">
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="/">首页</a></li>
        <li class="breadcrumb-item"><a href="{:url('Category/index', array('catid' => $catinfo.id))}">{$catinfo.catname}</a></li>
        <li class="breadcrumb-item"><a href="javascript:void(0);">{$bookinfo.bname}</a></li>
    </ol>
</nav>
<div class="row m-0">
    <div class="shop_detail_box">
        <div class="newbook_left">
            <div class="bookCover_area">
                <!-- 左侧图 -->
                <img src="{$bookinfo.thumb}" alt="{$bookinfo.bname}">
            </div>
            <div class="more_links">
                    <span id="collect_area">
                        <div class="collection" data-isstore="0">
                            <i class="icon collect"></i>
                            <a class="text" dd_name="收藏" id="collect">收藏</a>
                        </div>
                    </span>
                &nbsp;|&nbsp;
                <span id="share_area">
                        <div class="shareC">
                            <i class="icon share"></i>分享
                            <div class="sharelist clearfix hide">
                                <i class="weibo icon clicked" data-type="sina"></i>
                                <i class="weixin icon" data-type="weixin">
                                    <div class="weixinC hide"></div>
                                </i>
                                <i class="qq icon clicked" data-type="qzone"></i>
                            </div>
                        </div>
                    </span>
            </div>
        </div>
        <div class="newbook_center" id="productBookDetail">
            <!-- 图书描述 -->
            <h1 class="bookname_box">
                <span class="title_words" title="{$bookinfo.bname}">{$bookinfo.bname}</span>
            </h1>
            <div class="price_box">
                <div class="clearfix">
                    <div class="cost_box">
                        <p>售&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价： <span class="normal_price">¥<i>{$bookinfo.price}</i></span></p>
                    </div>
                    <div class="count_per text-sm">

                        {$bookinfo.number}人正在读
                        <!--| <em>0人评论</em>-->


                        <!--<img src="//img63.ddimg.cn/web/pcbookstore/readIndex_starLevel_full.png">-->


                        <!--<img src="//img63.ddimg.cn/web/pcbookstore/readIndex_starLevel_full.png">-->


                        <!--<img src="//img63.ddimg.cn/web/pcbookstore/readIndex_starLevel_full.png">-->


                        <!--<img src="//img63.ddimg.cn/web/pcbookstore/readIndex_starLeve_half.png">-->


                        <!--<img src="//img63.ddimg.cn/web/pcbookstore/readIndex_starLeve_empty.png">-->


                        <!--<em class="readIndex">7.2</em>-->
                    </div>
                </div>
            </div>
            <div class="explain_box">
                <p id="author" class="mb-0">作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;者：
                    <span>{$bookinfo.author}</span>
                </p>
                <p id="publisher" class="mb-0">出&nbsp;&nbsp;版&nbsp;&nbsp;社：<span>{$bookinfo.publish}</span></p>
                <p class="mb-0">所属分类：
                    <span><a href="{:url('Category/index', array('catid' => $catinfo.id))}" >{$catinfo.catname}</a></span>
                </p>
                <p id="total" class="">库&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;存：<span>{$bookinfo.total}</span></p>
            </div>
            <b style="display: none" id="cart_items_count"></b>
            <div class="newbtn_box btn_line clearfix">

                {if $uid}
                <a href="javascript:void(0)" class="green_btn_2 btn" id="addShopCartBtn">加入购物车</a>
                {else}
                <a href="{:url('User/login')}" class="green_btn_2 btn">加入购物车</a>
                {/if}
                <a href="javascript:void(0)" class="green_btn btn" id="buy_now_button">立即购买</a>
                <a href="{:url('Borrow/book', array('bookid' => $bookinfo.id))}" class="normal_btn btn" id="tryBtn">借阅</a>

                <input id="bookid" type="hidden" value="{$bookinfo.id}">
                <input id="product_title" type="hidden" value="{$bookinfo.bname}">
                <input id="product_desc" type="hidden" value="{$bookinfo.content}">
                <input id="product_coverPic" type="hidden" value="{$bookinfo.thumb}">
            </div>
            <p class="prompt">温馨提示：商品不支持退换货，不提供源文件，不支持导出打印</p>
        </div>
    </div>

    <div class="newTab_box">
        <ul class="tab_title p-0">
            <li class="cur" data-role="newEditModule">读书简介</li>
            <!--<li data-role="catalogModule" id="catalog_btn2" dd_name="目录">目录</li>-->
            <!--<li class="countBar" data-role="barModule" id="article_btn2" dd_name="累计评论">累计评论<span>(0条)</span></li>-->
        </ul>
    </div>

    <div class="newEdit_box" id="newEditModule">
        {$bookinfo.content}
    </div>


</div>
{/block}

{block name="js"}
<script>
$(function () {
    let lock = false;
   $("#addShopCartBtn").on('click', function () {
       if (lock) {
           return false;
       }
       lock = true;
       $.post("{:url('Cart/add')}", {bookid: $("#bookid").val()},function (res) {
           if (res.code == 0) {
               swal("提示", res.msg, {
                   icon : "error",
                   buttons: {
                       confirm: {
                           className : 'btn btn-danger',
                           text : '确定',
                       }
                   },
               });
           } else{
               swal("提示", res.msg, {
                   icon : "success",
                   buttons: {
                       confirm: {
                           className : 'btn btn-success',
                           text : '确定',
                       }
                   }
               }).then(function () {
                   $("#cart_num").html(res.data);
               });
           }
           lock = false;
       }, 'json');
   });
});
</script>
{/block}